//
//  UIBarButtonItem+Category.swift
//  DSWeibo
//
//  Created by Colin on 16/6/10.
//  Copyright © 2016年 Colin. All rights reserved.
//

import UIKit
extension UIBarButtonItem
{
    
    //如果在func前加class，就相当于oc中的类方法
    class func createBarButtonItem(imageNme:String,target:AnyObject?,action:Selector) -> UIBarButtonItem
    {
        //command + control + e
        let btn = UIButton()
        btn.setImage(UIImage(named: imageNme), forState: UIControlState.Normal)
        btn.setImage(UIImage(named: (imageNme + "_highlighted")), forState: UIControlState.Highlighted)
        btn.sizeToFit()
        btn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        return UIBarButtonItem(customView: btn)

    }
}
